// /utils/mock.js
export const showToast = (title) => {
  // 模拟UniApp的showToast方法
  if (typeof uni !== 'undefined') {
    uni.showToast({
      title,
      icon: 'none',
      duration: 2000
    });
  } else {
    // H5环境下的模拟
    const toast = document.createElement('div');
    toast.style.position = 'fixed';
    toast.style.bottom = '100px';
    toast.style.left = '50%';
    toast.style.transform = 'translateX(-50%)';
    toast.style.padding = '10px 20px';
    toast.style.backgroundColor = 'rgba(0,0,0,0.7)';
    toast.style.color = 'white';
    toast.style.borderRadius = '5px';
    toast.style.zIndex = '9999';
    toast.textContent = title;
    document.body.appendChild(toast);
    
    setTimeout(() => {
      toast.remove();
    }, 2000);
  }
};

// 模拟用户数据
export const mockUser = {
  id: '123456',
  username: 'testuser',
  phone: '13800138000',
  avatar: '/static/avatar.png'
};

// 模拟登录接口
export const mockLogin = (params) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 0,
        message: '登录成功',
        data: {
          token: 'mock-token-123456',
          user: mockUser
        }
      });
    }, 1000);
  });
};
